﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Table_Dal;
namespace DAL
{
    public class DiemDAL:DataAccessLayer
    {
        DataDataContext dt;
        public void Luu(DiemTbl diem)
        {
            dt = GetKetnoi();
            DIEM d = dt.DIEMs.Where(n => n.MADETHI == diem.MaDeThi).Where(j => j.MSSV == diem.MSSV).Single();
            d.DIEM1 = diem.Diem;
            dt.SubmitChanges();
        }

        public void Xoa(string item, string tempt)
        {
            dt = GetKetnoi();
            DIEM d = dt.DIEMs.Where(i => i.MSSV == item).Where(j => j.MADETHI == tempt).Single();
            dt.DIEMs.DeleteOnSubmit(d);
            dt.SubmitChanges();
        }

        public void Them(DiemTbl dtbl)
        {
            dt = GetKetnoi();
            DIEM d = new DIEM();
            d.MSSV = dtbl.MSSV;
            d.MADETHI = dtbl.MaDeThi;
            d.DIEM1 = null;
            dt.DIEMs.InsertOnSubmit(d);
            dt.SubmitChanges();
        }
    }
}
